home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Computer Select (Limited Edition)
/
Computer Select.iso
/
pcc
/
v04n10
/
contacts.bas
< prev
next >
Wrap
BASIC Source File
|
1991-06-24
|
3KB
|
67 lines
filename$ = "CONTACTS.TXT" ' Name of contacts database file
form$ = "\ \ \ \ (\ \)-\ \"
' Display the main menu
MainMenu:
CLS : LOCATE 7, 25: PRINT "BUSINESS CONTACTS DATABASE"
LOCATE 11, 25: PRINT "------------ MAIN MENU -------------"
LOCATE 14, 25: PRINT "1. ADD a name to the database"
LOCATE 16, 25: PRINT "2. SEARCH for a name in the database"
LOCATE 18, 25: PRINT "3. QUIT this program"
LOCATE 21, 25: PRINT "Please press 1, 2, or 3"
' Get the user's choice
DO: choice$ = INKEY$
LOOP UNTIL choice$ = "1" OR choice$ = "2" OR choice$ = "3"
SELECT CASE choice$
CASE "1" ' Add a name to the database
OPEN filename$ FOR APPEND AS #1
WHILE UCASE$(last$) <> "END"
CLS : LOCATE 11, 25: PRINT "ADD a name to the database"
LOCATE 12, 25: PRINT "(To stop, enter END as a last name)"
LOCATE 14, 25: INPUT "Last name: ", last$
IF UCASE$(last$) <> "END" THEN
LOCATE 16, 24: INPUT "First name: ", first$
LOCATE 18, 40: PRINT "(Press Enter if n/a)"
LOCATE 18, 25: INPUT "Area code: ", area$
LOCATE 20, 22: INPUT "Phone number: ", phone$
WRITE #1, last$, first$, area$, phone$: CLS
END IF
WEND
CLOSE #1: last$ = "": GOTO MainMenu
CASE "2" ' Search for a name in the database
WHILE UCASE$(search$) <> "END"
OPEN filename$ FOR INPUT AS #1
CLS : LOCATE 11, 25: PRINT "SEARCH for a name in the database"
LOCATE 12, 25: PRINT "(To stop, enter END as the name)"
LOCATE 14, 25: INPUT "Name to search for: ", search$: PRINT
IF UCASE$(search$) <> "END" THEN
DO WHILE (NOT EOF(1))
INPUT #1, last$, first$, area$, phone$
SELECT CASE UCASE$(search$)
CASE UCASE$(last$)
hit% = 1: LOCATE , 25
PRINT USING form$; last$; first$; area$; phone$
CASE UCASE$(first$)
hit% = 1: LOCATE , 25
PRINT USING form$; last$; first$; area$; phone$
END SELECT
LOOP
IF hit% = 0 THEN
LOCATE , 25: PRINT "No match found for "; search$
END IF
hit% = 0: LOCATE , 25: PRINT
LOCATE , 25: PRINT "Press any key to continue"
DO WHILE INKEY$ = "": LOOP
CLOSE #1
END IF
WEND
CLOSE #1: search$ = "": GOTO MainMenu
CASE "3" ' Quit the program
CLS : SYSTEM
END SELECT